export const flatten = (array, condition) => {
  return array.reduce((sum, item) => {
    if (Array.isArray(item.children)) {
      return sum.concat(flatten(item.children, condition))
    }
    if (condition(item)) {
      return sum.concat(item)
    }
    return sum
  }, [])
}

export const guid = () => '_' + new Date().getTime().toString(16).slice(6) + Math.random().toString(16).slice(3, 6)
